package web.opinion;

import java.sql.Timestamp;
import java.util.List;

import model.Opinion;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class OpinionAction extends ActionSupport implements Action {

	private static final long serialVersionUID = 1L;


	//変数
	private List<Opinion> opinionList;
	private Opinion opinion;

	private String opinionid;
	private String contents;
	private Timestamp createDate;
	private Integer status;
	private Integer counter;
	private String dept;
	private String comment;
	private Timestamp commentDate;
	private String commentUser;

	private String readpage;
	public String getReadpage() {
		return readpage;
	}
	public void setReadpage(String readpage) {
		this.readpage = readpage;
	}

	private String search;
	private Integer pageStatus;

	//setter, getter
	public List<Opinion> opinionList() {
		return opinionList;
	}
	public void setList(List<Opinion> opinionList) {
		this.opinionList = opinionList;
	}
	public Opinion getOpinion() {
		return opinion;
	}
	public void setOpinion(Opinion opinion) {

		this.opinion = opinion;
	}
	public String getOpinionid() {
		return opinionid;
	}
	public void setOpinionid(String opinionid) {
		this.opinionid = opinionid;
	}
	public String getContents() {
		return contents;
	}
	public void setContents(String contents) {
		this.contents = contents;
	}
	public Timestamp getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Timestamp createDate) {
		this.createDate = createDate;
	}
	public Integer getStatus() {
		return status;
	}
	public void setStatus(Integer status) {
		this.status = status;
	}
	public Integer getCounter() {
		return counter;
	}
	public void setCounter(Integer counter) {
		this.counter = counter;
	}
	public String getDept() {
		return dept;
	}
	public void setDept(String dept) {
		this.dept = dept;
	}
	public String getComment() {
		return comment;
	}
	public void setComment(String comment) {
		this.comment = comment;
	}
	public Timestamp getCommentDate() {
		return commentDate;
	}
	public void setCommentDate(Timestamp commentDate) {
		this.commentDate = commentDate;
	}
	public String getCommentUser() {
		return commentUser;
	}
	public void setCommentUser(String commentUser) {
		this.commentUser = commentUser;
	}
	public List<Opinion> getOpinionList() {
		return opinionList;
	}
	public void setOpinionList(List<Opinion> opinionList) {
		this.opinionList = opinionList;
	}
	public String getSearch() {
		return search;
	}
	public void setSearch(String search) {
		this.search = search;
	}
	public Integer getPageStatus() {
		return pageStatus;
	}
	public void setPageStatus(Integer pageStatus) {
		this.pageStatus = pageStatus;
	}

	public String init() throws Exception {
		return SUCCESS;
	}

	public String write() throws Exception {
		return SUCCESS;
	}

	/**
	 * コンテンツリスト
	 * @return
	 * @throws Exception
	 */
	public String select() throws Exception{
		//service
		OpinionService service = new OpinionService();
		service.getList(this);
		return SUCCESS;
	}

	/**
	 * コンテンツ検索リスト
	 * @return
	 * @throws Exception
	 */
	public String searchList() throws Exception{
		OpinionService service = new OpinionService();
		service.getSearchList(this);
		return SUCCESS;
	}


	/**
	 * コンテンツカウント増加
	 * @return
	 * @throws Exception
	 */
	public String addCounter() throws Exception{
		OpinionService service = new OpinionService();
		service.addCounter(this);
		if(this.getReadpage().equals("ok"))
			return "read";
		return SUCCESS;
	}

	/**
	 * コンテンツ追加
	 * @return
	 * @throws Exception
	 */
	public String regist() throws Exception{
		OpinionService service = new OpinionService();
		service.regist(this);
		this.setPageStatus(9);
		service.getList(this);
		return SUCCESS;
	}
}
